home *** CD-ROM | disk | FTP | other *** search
- /*
- * WinLIB
- * Internal library handler
- */
-
- #include "winlib.h"
- #include "internal.h"
- #include "config.h"
-
- int Win_LibHandler(Gpm_Event *event, void *data)
- {
- /* Fit all mouse events into the screen instead of one outside the
- margin, as GPM defaults to */
- Gpm_FitEvent(event);
-
- #ifdef MOUSE_COORD
- /* Display event-specific info */
- if (_has_menu) {
- wattron(_menu_win, A_REVERSE);
- mvwprintw(_menu_win, 0, 40, "%03dX %02dY %02d %04x %01d %02d %d",
- event->x, event->y, event->buttons, event->type, _cur_title,
- _cur_window, _resize_corner);
- wattroff(_menu_win, A_REVERSE);
- }
- #endif
-
- /* Dispatch to menu handling routine if necessary */
- if ((_has_menu) && (event->y == 0) && (!_moving_win) && (!_resizing_win))
- if ((event->buttons == GPM_B_LEFT) &&
- (event->type & (GPM_DOWN | GPM_DRAG))) {
- if ((_showing_menu) && (_cur_item != -1))
- _unselect_item();
-
- _handle_menu(event);
- } else
- _unselect_menu();
-
- /* Now check to see if our mouse is within the bounds of the dropdown
- menu if it's present. */
- if ((_has_menu) && (_showing_menu) && (!_moving_win) && (!_resizing_win)) {
- if ((event->y >= _menu_area->_begy) &&
- (event->y <= (_menu_area->_begy + _menu_area->_maxy)) &&
- (event->x >= _menu_area->_begx) &&
- (event->x <= (_menu_area->_begx + _menu_area->_maxx)))
- _handle_menu_selection(event);
- else
- _unselect_item();
- }
-
- /* Check to see if the mouse was released in any menus */
- if ((_has_menu) && (_showing_menu) && (_cur_item == -1) &&
- (!(event->type & (GPM_DOWN | GPM_DRAG))) && (!_resizing_win))
- _unselect_menu();
-
- /* Now, check to see whether we've clicked on a window or not */
- if (_has_win) {
- if (!_moving_win)
- _handle_resize(event);
-
- if (!_resizing_win)
- _handle_window(event);
- }
-
- /* Call the mouse dispatcher in case one exists */
- if (_mousedispatch)
- (_mousedispatch)(event);
-
- /* Redraw the screen with the update panels at the very last. */
- update_panels();
- doupdate();
-
- return(TRUE);
- }
-
- void Win_Loop(void)
- {
- int c;
-
- while((c = Gpm_Getch()) != EOF) {
- if (_keydispatch) {
- if (c != 1)
- (_keydispatch)(c);
- }
- }
- }
-